<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script src="../node_modules/jquery/dist/jquery.js"></script>
<script>
    function queryData(url) {
        var p = new Promise(function (resolve, reject) {
            var xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function () {
                if (xhr.readyState != 4) return;
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        resolve(xhr.responseText);

                    }
                } else {
                    reject(xhr.status);
                }
            }
            xhr.open('get', url);
            xhr.send(null);
        })
        return p;
    };


    queryData('http://127.0.0.1/data').then(function (data) {
       return queryData('http://127.0.0.1/data')
    }, function (info) {
        console.log('not ok')
        console.log(info)
    }).then(function(data){
        return new Promise(function(resolve,reject){
            setTimeout(function () { 
                resolve(123);
             },1000)
        })
    }).then(function(data){
        console.log(data)
    })


    // $.ajax({
    //     type: "get",
    //     url: "http://127.0.0.1/data",
    //     dataType: "text",
    //     success: function (response) {
    //         console.log(response)
    //     }
    // });
</script>
</body>
</html>